package com.scau.service.impl.business;

import java.io.Serializable;

import org.springframework.stereotype.Component;

import com.scau.exception.BusinessException;
import com.scau.model.business.Supplier;
import com.scau.service.BaseService;

@Component
public class SupplierService extends BaseService<Supplier> implements Serializable{
	
	public void save(Supplier sp) throws BusinessException{
		if (null != sp && null != sp.getName()) {
			if(null != sp.getId()&& 0 != sp.getId()){
				update(sp);
			}else{
				add(sp);
			}
		}else {
			throw new BusinessException("名称不能为空");
		}
	}
	
	@Override
	public Supplier get(Supplier supplier){
		if (null!=supplier&&null!=supplier.getId()&&0!=supplier.getId()) {
			return super.get(supplier, supplier.getId());
		}else if (null!=supplier) {
			return super.get(supplier);
		}else {
			return null;
		}
	}
	
}